<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/sys/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<%@ include file="/WEB-INF/adminui/include/css.jsp" %>
<title>二维码管理</title>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
	<div class="row">
	<div class="col-sm-2">
			<div class="ibox ibox-body">
				<div class="ibox-title">
					<h5>选择园区</h5>
				</div>
				<div class="ibox-content">
					<div id="jstree"></div>
				</div>
			</div>
		</div>
		<div class="col-sm-9">
			<div class="ibox">
				<div class="ibox-body">
					<div class="fixed-table-toolbar">
						<div id="toolbar" class="columns pull-left">
							<c:if test="${type == 1}">
							<qx:perm code="qrcode_zz_add">
							<button type="button" class="btn btn-primary" onclick="add()" uilist-prem="group_GROUP_EDIT" uilist-hide="GROUP">
								<i class="fa fa-plus hidden" aria-hidden="true"></i>添加
							</button>
							</qx:perm>
							</c:if>
							<c:if test="${type == 2}">
							<qx:perm code="qrcode_yz_add">
							<button type="button" class="btn btn-primary" onclick="add()" uilist-prem="group_GROUP_EDIT" uilist-hide="GROUP">
								<i class="fa fa-plus hidden" aria-hidden="true"></i>添加
							</button>
							</qx:perm>
							</c:if>
							<c:if test="${type == 3}">
							<qx:perm code="qrcode_jg_add">
							<button type="button" class="btn btn-primary" onclick="add()" uilist-prem="group_GROUP_EDIT" uilist-hide="GROUP">
								<i class="fa fa-plus hidden" aria-hidden="true"></i>添加
							</button>
							</qx:perm>
							</c:if>
							
						</div>
					</div>
					<table id="dataTable" data-mobile-responsive="true">
					</table>
				</div>
			</div>
		</div>
	</div>
</div>
<%@ include file="/WEB-INF/adminui/include/script.jsp" %>
<script type="text/javascript">
$(function(){
	UiList.render({
		treeUrl: '${path}/parkjstree/menudata.json?module=well',
		tableConfig:{
			url: "${path}/qrCode/listdata.json?type=${type}",
			idfield: 'codeid',
			columns: [
				{checkbox : true},
				{field : 'companyName', title : '企业名称'},
				{field : 'companycode', title : '企业编码'},
				{field : 'parkName', title : '园区名称'},
				{field : 'parkcode', title : '园区编码'},
				{field : 'cropName', title : '作物名称'},
				{field : 'cropcode', title : '作物编码'},
				{field : 'shu', title : '数量'},
				{field : 'qrcodeStart', title : '开始编码'},
				{field : 'qrcodeEnd', title : '结束编码'},
				{field : 'createTime', title : '添加时间', formatter : function(value, row, index) {
					return formatDate(value, 'yyyy-MM-dd HH:mm:ss');
				}},
				/* {field : 'is_activation', title : '是否开通',formatter : function(value, row, index) {
					switch(''+value){
					case '0': return '未开通';
					case '1': return '已开通';
					}
					return ''+value;
				}} */
				{field : 'codeid', title : '操作', align : 'center', formatter : function(value, row, index) {
					var s = '';
					var type = '${type}'
					if(type==1){
					<qx:perm code="qrcode_zz_show">
					s += '<a class="btn btn-primary btn-sm" href="javascript:;0" title="二维码列表" onclick="qrCodeShow(\''+value+'\')">二维码</a> ';
					</qx:perm>
					
					<qx:perm code="qrcode_zz_del">
					s += '<a class="btn btn-danger btn-sm" href="javascript:;" title="删除" onclick="del(\''+value+'\')">删除</a>';
					</qx:perm>
					}else if(type == 2){
						<qx:perm code="qrcode_yz_show">
						s += '<a class="btn btn-primary btn-sm" href="javascript:;0" title="查看二维码" onclick="qrCodeShow(\''+value+'\')">二维码</a> ';
						</qx:perm>
						
						<qx:perm code="qrcode_yz_del">
						s += '<a class="btn btn-danger btn-sm" href="javascript:;" title="删除" onclick="del(\''+value+'\')">删除</a>';
						</qx:perm>
					}else if(type == 3){
						<qx:perm code="qrcode_jg_show">
						s += '<a class="btn btn-primary btn-sm" href="javascript:;0" title="查看二维码" onclick="qrCodeShow(\''+value+'\')">二维码</a> ';
						</qx:perm>
						
						<qx:perm code="qrcode_jg_del">
						s += '<a class="btn btn-danger btn-sm" href="javascript:;" title="删除" onclick="del(\''+value+'\')">删除</a>';
						</qx:perm>
					}
					return s;
				}}
			]
		},
		tableParams: function(){//搜索条件
			return {search: $("#searchName").val()};
		}
	});
	
});

function qrCodeShow(id){
	UiList.open('${path}/qrCode/showQrNum.do?codeid='+id, '二维码列表',{width:600,height:700});
}
function add(){
	UiList.open('${path}/qrCode/add.do?type=${type}', '添加二维码信息', {refresh:true});
}
function del(id){
	UiList.dialog('${path}/qrCode/delete.json?codeid='+id, '您确定要删除选中的二维码信息吗？', '删除二维码信息成功.', {refresh:true,useTableData:false});
}
</script>
</body>
</html>